package php.code.functions;

import php.code.instructions.Instruction;

import java.util.Arrays;
import java.util.List;

/**
 * Created by nuno-rafael-figueiredo on 25-05-2014.
 */
public class Function extends Instruction {
    protected final TextLayout textLayout;
    protected final List<String> lines;

    public Function(TextLayout textLayout, List<String> lines) {
        super(false);
        this.textLayout = textLayout;
        this.lines = lines;
    }

    public Function(TextLayout textLayout, String... lines) {
        this(textLayout, Arrays.asList(lines));
    }

    protected static String wrap(Object key) {
        return key instanceof String ? "'" + key + "'" : key.toString();
    }


    @Override
    protected String getCode() {
        return textLayout.format(this, lines);
    }
}
